package org.game.plugin.event;

import java.util.Map;

import org.constant.EventConditionKey;
import org.game.db.bean.Player;

import com.sojoys.artifact.tools.ToolMap;

/**
 * 事件监听器
 * @author SandKing
 *
 */
public interface GameEventListener {
	
    public void onEvent(GameEvent event);
    /**
     * 初始化事件进度
     * @param player
     * @param eventStack
     */
    public void initEventCondition(Player player,GameEventStack eventStack);
    
    
    /**
     * 检查触发类型
     * @param in
     * @param triggerCode
     * @return
     */
    default boolean checkTriggerType(Map in,int triggerCode){
    	return ToolMap.getInt(EventConditionKey.CONDITION_TYPE, in) == triggerCode;
    }
    
    /**
     * 小于
     * @return
     */
    default boolean verify_lt(String key,Map in,Map Params){
    	int condition = ToolMap.getInt(key, Params,0);
    	if (condition != 0) {
    		int number = ToolMap.getInt(key, in, 0);
    		return number < condition;
		}
    	return true;
    }
    
    /**
     * 小于等于
     * @return
     */
    default boolean verify_le(String key,Map in,Map Params){
    	int condition = ToolMap.getInt(key, Params, 0);
    	if (condition != 0) {
    		int number = ToolMap.getInt(key, in, 0);
    		return number <= condition;
		}
    	return true;
    }
    
    /**
     * 大于
     * @return
     */
    default boolean verify_gt(String key,Map in,Map Params){
    	int condition = ToolMap.getInt(key, Params, 0);
    	if (condition != 0) {
    		int number = ToolMap.getInt(key, in, 0);
    		return number > condition;
		}
    	return true;
    }
    
    /**
     * 大于等于
     * @return
     */
    default boolean verify_ge(String key,Map in,Map Params){
    	int condition = ToolMap.getInt(key, Params, 0);
    	if (condition != 0) {
    		int number = ToolMap.getInt(key, in, 0);
    		return number >= condition;
		}
    	return true;
    }
    
    /**
     * 等于
     * @return
     */
    default boolean verify_eq(String key,Map in,Map Params){
    	int condition = ToolMap.getInt(key, Params, 0);
    	if (condition != 0) {
    		int number = ToolMap.getInt(key, in, 0);
    		return number == condition;
		}
    	return true;
    }

	/**
	 * 不等于
	 * @return
	 */
	default boolean verify_not_eq(String key,Map in,Map Params){
		int condition = ToolMap.getInt(key, Params, 0);
		if (condition != 0) {
			int number = ToolMap.getInt(key, in, 0);
			return number != condition;
		}
		return true;
	}
}
